package solution1.demo_t;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

//1.
class MyThread extends Thread {

    @Override
    public void run() {
        System.out.println("创建线程1");
    }

}

//2.
class MyRunnable implements Runnable {

    @Override
    public void run() {
        System.out.println("创建线程2");
    }

}

class MyCall implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        System.out.println("创建线程6");
        return 0;
    }
}

public class Solution {

    public static void main(String[] args) {
        MyThread myThread = new MyThread();
        myThread.start();
        Thread thread2 = new Thread(new MyRunnable());
        thread2.start();
        Thread thread3 = new Thread() {
            @Override
            public void run() {
                System.out.println("创建线程3");
            }
        };
        thread3.start();
        Thread thread4 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("创建线程4");
            }
        });
        thread4.start();

        Thread thread5 = new Thread(() -> {
            System.out.println("创建线程5");
        });
        thread5.start();

        FutureTask<Integer> task = new FutureTask<>(new MyCall());
        Thread thread6 = new Thread(task);
        thread6.start();

        ExecutorService pool = Executors.newCachedThreadPool();
        pool.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println("创建线程7");
            }
        });
    }

}
